<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>debug_adaptor</title>
<link rel="stylesheet" href="../../../multiprecision.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../index.html" title="Chapter 1. Boost.Multiprecision">
<link rel="up" href="../misc.html" title="Miscellaneous Number Types.">
<link rel="prev" href="logged_adaptor.html" title="logged_adaptor">
<link rel="next" href="visualizers.html" title="Visual C++ Debugger Visualizers">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="logged_adaptor.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../misc.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="visualizers.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="boost_multiprecision.tut.misc.debug_adaptor"></a><a class="link" href="debug_adaptor.html" title="debug_adaptor">debug_adaptor</a>
</h4></div></div></div>
<p>
          <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multiprecision</span><span class="special">/</span><span class="identifier">debug_adaptor</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>
        </p>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">multiprecision</span><span class="special">{</span>

<span class="keyword">template</span> <span class="special">&lt;</span><span class="identifier">Backend</span><span class="special">&gt;</span>
<span class="keyword">class</span> <span class="identifier">debug_adaptor</span><span class="special">;</span>

<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Number</span><span class="special">&gt;</span>
<span class="keyword">using</span> <span class="identifier">debug_adaptor_t</span> <span class="special">=</span> <span class="identifier">number</span><span class="special">&lt;</span><span class="identifier">debug_adaptor</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Number</span><span class="special">::</span><span class="identifier">backend_type</span><span class="special">&gt;,</span> <span class="identifier">Number</span><span class="special">::</span><span class="identifier">et</span><span class="special">&gt;</span>

<span class="special">}}</span> <span class="comment">// namespaces</span>
</pre>
<p>
          The <code class="computeroutput"><span class="identifier">debug_adaptor</span></code> type
          is used in conjunction with <code class="computeroutput"><span class="identifier">number</span></code>
          and some other backend type: it acts as a thin wrapper around some other
          backend to class <code class="computeroutput"><span class="identifier">number</span></code>
          and intercepts all operations on that object storing the result as a string
          within itself.
        </p>
<p>
          This type provides <code class="computeroutput"><span class="identifier">numeric_limits</span></code>
          support whenever the template argument Backend does so.
        </p>
<p>
          This type is particularly useful when your debugger provides a good view
          of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code>: when this is the case multiprecision
          values can easily be inspected in the debugger by looking at the <code class="computeroutput"><span class="identifier">debug_value</span></code> member of <code class="computeroutput"><span class="identifier">debug_adaptor</span></code>.
          The down side of this approach is that runtimes are much slower when using
          this type. Set against that it can make debugging very much easier, certainly
          much easier than sprinkling code with <code class="computeroutput"><span class="identifier">printf</span></code>
          statements.
        </p>
<p>
          When used in conjunction with the Visual C++ debugger visualisers, the
          value of a multiprecision type that uses this backend is displayed in the
          debugger just a <a href="https://en.cppreference.com/w/cpp/language/types" target="_top">fundamental
          (built-in)</a> value would be, here we're inspecting a value of type
          <code class="computeroutput"><span class="identifier">number</span><span class="special">&lt;</span><span class="identifier">debug_adaptor</span><span class="special">&lt;</span><span class="identifier">cpp_dec_float</span><span class="special">&lt;</span><span class="number">50</span><span class="special">&gt;</span> <span class="special">&gt;</span>
          <span class="special">&gt;</span></code>:
        </p>
<p>
          <span class="inlinemediaobject"><img src="../../../../debugger1.png"></span>
        </p>
<p>
          Otherwise you will need to expand out the view and look at the "debug_value"
          member:
        </p>
<p>
          <span class="inlinemediaobject"><img src="../../../../debugger2.png"></span>
        </p>
<p>
          It works for all the backend types equally too, here it is inspecting a
          <code class="computeroutput"><span class="identifier">number</span><span class="special">&lt;</span><span class="identifier">debug_adaptor</span><span class="special">&lt;</span><span class="identifier">gmp_rational</span><span class="special">&gt;</span>
          <span class="special">&gt;</span></code>:
        </p>
<p>
          <span class="inlinemediaobject"><img src="../../../../debugger3.png"></span>
        </p>
<p>
          The template alias <code class="computeroutput"><span class="identifier">debug_adaptor_t</span></code>
          is used as a shortcut for converting some other number type to it's debugged
          equivalent, for example:
        </p>
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">mpfr_float_debug</span> <span class="special">=</span> <span class="identifier">debug_adaptor_t</span><span class="special">&lt;</span><span class="identifier">mpfr_float</span><span class="special">&gt;;</span>
</pre>
<p>
          Defines <code class="computeroutput"><span class="identifier">mpfr_float_debug</span></code>
          to be the debugged equivalent of <code class="computeroutput"><span class="identifier">mpfr_float</span></code>.
        </p>
</div>
<div class="copyright-footer">Copyright © 2002-2020 John
      Maddock and Christopher Kormanyos<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="logged_adaptor.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../misc.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="visualizers.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
